<template>
  <div class="flex flex-a-c">
    <div
      class="statusBox flex flex-a-c flex-j-s-b"
      v-for="(item, index) in option"
      :class="current === index ? 'statusActive' : ''"
      :key="index"
      @click="onChange(index)"
    >
      <div class="statusIcon" v-if="current !== index"></div>
      <div class="activeIcon" v-else>
        <span class="ring-style"></span>
      </div>
      <div>
        {{ item.label }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Number,
      default: 0,
    },
    option: {
      type: Array,
    },
    name: {
      type: String,
    },
  },
  mounted() {},
  watch: {
    value(newValue) {
      this.current = newValue;
    },
  },
  data() {
    return {
      current: 0,
    };
  },
  methods: {
    onChange(value) {
      this.current = value;
      this.$emit("changeRadio", this.name, value);
    },
  },
};
</script>

<style lang="less" scoped>
.statusBox {
  width: 80px;
  height: 36px;
  background: #ffffff;
  border: 1px solid #dcdfe6;
  border-radius: 2px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 400;
  margin-right: 10px;
}
.statusActive {
  background: rgba(26, 94, 255, 0.1);
  border: 1px solid #1a5eff;
  color: #1a5eff;
}
.statusIcon {
  width: 12px;
  height: 12px;
  border: 1px solid #dcdfe6;
  border-radius: 50%;
}

.activeIcon {
  position: relative;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border: 4px solid #1a5eff;
  border-radius: 50%;
  background-color: lightgrey;
}

.ring-style {
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: blue;
  width: 4px;
  height: 4px;
  border-radius: 260px;
}

.ring-style::before {
  content: " ";
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  width: 4px;
  height: 4px;
  border-radius: 200px;
}
</style>
